/*!
 * @author Isis (igraziatto) Graziatto <isis.g@vanillaforums.com>
 * @copyright 2009-2018 Vanilla Forums Inc.
 * @license GPL-2.0-only
 */

/* -------------------------------------------------------------- *\
    Variables
\* -------------------------------------------------------------- */

$pager_height: $formButton_height !default;
$pager_lineHeight: $formButton_height !default;
$pager_fontSize: $formButton_fontSize !default;
$pager_fontWeight: $formButton_fontWeight !default;
$pager_borderRadius: $formButton_borderRadius !default;
$pager_border: $component_border !default;

$pager_bg: $component_bg !default;
$pager-hover_bg: $theme-hover_color !default;
$pager_color: $global-color_fg !default;

$pager-highlight_bg: $pager-hover_bg !default;
$pager-highlight-border: $pager_border !default;
$pager-highlight_color: $global-color_primaryAlt !default;

$quickSearch_bg: $button-primary_bg !default;
$quickSearch_fg: $button-primary_fg !default;
$quickSearch_borderColor: $button-primary_border !default;

$quickSearch-hover_bg: $button-primary-hover_bg !default;
$quickSearch-hover_fg: $button-primary-hover_fg !default;
$quickSearch-hover_borderColor: $button-primary-hover_border !default;

$xs_breakpoint: 320px;

/* -------------------------------------------------------------- *\
    Styles
\* -------------------------------------------------------------- */

.PrevNextPager {
    width: 100%;

    .Previous,
    .Next {
        height: auto;
        min-height: 0;
    }

    .Next {
        margin-left: auto;
    }
}

.MorePager {
    margin-top: $component-item_spacing;
    text-align: center;
    color: $component-meta-link_color;

    &:focus,
    &:hover {
        color: $component-meta-link-hover_color;
    }

    a {
        color: inherit;

        &:focus,
        &:hover {
            color: inherit;
        }
    }
}

.PrevNextPager .Previous,
.PrevNextPager .Next {
    @include Button;

    flex: initial;
    min-width: 120px;
    text-align: center;
}

.PagerWrap,
.CommentsWrap {
    @include clearfix;
}

.PagerWrap {
    margin: 0;
    float: right;

    @media (max-width: #{$xs_breakpoint}) {
        float: none;
    }
}

.PagerNub {
    display: none;
}

.CommentHeading {
    @if $staticVariables {
        float: left;
    }
    min-height: $pager_height;
    display: flex;
    align-items: center;
    margin: 0 0 $utility-baseUnit;
}

.BeforeCommentHeading {
    margin-bottom: $global-block_margin;
    @media (max-width: #{$xs_breakpoint}) {
        float: none;
    }
}

.PageControls {
    @include clearfix;
    min-height: initial;
    margin: initial;
    margin-bottom: $global-block_margin;

    .H {
        margin-bottom: $global-block_margin;
    }
}

.QuickSearch .MenuItems {
    @include clearfix;

    right: -2px;
    top: 100%;

    .InputBox {
        margin-right: $utility-baseUnitDouble;
    }

    .bwrap {
        position: static;
        margin-left: $utility-baseUnitHalf;

        button {
            padding: 0;
        }
    }

    form > div {
        display: flex;
    }
}

a.MoreWrap,
.MoreWrap a,
.more.More {
    color: $global-color_primary;

    &:focus,
    &:hover {
        color: $global-color_primary;
    }
}

.Pager {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;

    @include maxWidth {
        float: none;
        width: 100%;
        justify-content: center;
        margin-bottom: $utility-baseUnitDouble;

        .QuickSearch {
            display: none;
        }
    }

    .QuickSearchButton {
        display: inline-flex;
        align-items: center;
        margin: 0 0 0 $utility-baseUnitDouble;
    }

    span,
    > a {
        transition: color 0.25s ease-out;
        font-size: $pager_fontSize;
        font-weight: $pager_fontWeight;
        line-height: $pager_height;
        height: $pager_height;
        min-width: $pager_height;
        display: flex;
        align-items: center;
        justify-content: center;
        color: $pager_color;
        padding: 0;
        margin: 0 0 0 -1px;
        border: $pager_border;
        @if ($staticVariables) {
            background: $pager_bg;

            &:focus,
            &:hover {
                background: $pager-hover_bg;
                z-index: 1;
            }
        }
    }

    @if ($staticVariables) {
        > a.Highlight,
        > a.Highlight:focus,
        > a.Highlight:hover {
            position: relative;
            z-index: 1;
            background: $pager-highlight_bg;
            border: 1px solid $pager-highlight-border;
            color: $pager-highlight_color;
        }
    }

    > a.Ellipsis {
        font-size: 0;
        background: none;
        padding-bottom: 0;

        &::after {
            font-size: 11px;
            font-weight: normal;
            content: "•••";
        }
    }

    .Next,
    .Previous {
        padding: 0 $utility-baseUnitDouble;
        text-align: center;
    }

    .Previous {
        border-top-left-radius: $pager_borderRadius;
        border-bottom-left-radius: $pager_borderRadius;
    }

    .Next {
        border-top-right-radius: $pager_borderRadius;
        border-bottom-right-radius: $pager_borderRadius;
    }

    @if ($staticVariables) {
        .QuickSearchWrap .Button,
        .QuickSearchButton {
            @include Button(
                $quickSearch_bg,
                $quickSearch_fg,
                $quickSearch_borderColor,
                $quickSearch-hover_bg,
                $quickSearch-hover_fg,
                $quickSearch-hover_borderColor
            );
        }
    }

    .QuickSearchButton {
        height: $formButton_height;
        min-width: $formButton_height;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .QuickSearchButton.QuickSearchButton span {
        display: inherit;
        color: inherit;

        &:hover,
        &:focus {
            color: inherit;
            background-color: transparent;
        }
    }

    .QuickSearchWrap {
        width: 300px;
    }

    .bwrap .Button {
        line-height: $formButton-height;
        height: $formButton-height;
    }
}

.selectBox-toggle {
    color: $global-color_primary;
}

//Responsive .NumberedPager
@include maxWidth(500px) {
    .PagerLinkCount-13 {
        .Pager-p:not(.Highlight):not(.LastPage) {
            display: none;
        }
    }

    .Pager {
        display: flex;
        flex-wrap: nowrap;

        a,
        span {
            white-space: nowrap;
            min-width: 34px;
            flex: 1;
            padding-left: 0;
            padding-right: 0;
        }
    }
}

@include maxWidth(470px) {
    .PagerLinkCount-11 {
        .Pager-p:not(.Highlight):not(.LastPage) {
            display: none;
        }
    }
}

.PageControls.PageControls {
    .discussion-sorts {
        margin-right: $utility-baseUnitDouble;
    }

    @include maxWidth {
        margin: 0;
        display: flex;
        flex-wrap: wrap;

        .selectBox {
            display: inline-block;
        }
    }

    .BoxNewConversation,
    .BoxNewDiscussion,
    .QuickSearch {
        display: none;
    }

    // Reset styles from ideation
    .discussion-sort-filter-module {
        float: none !important;
        display: inline-flex;
    }

    .selectBox {
        display: inline-flex;
        float: none;
        height: #{$pager_height + 2px};

        @if $staticVariables {
            @include maxWidth {
                margin: 0;
            }
        }
    }
}

.Button-Controls.Button-Controls {
    .BigButton,
    .ButtonGroup.Multi {
        min-width: 200px;
    }

    .BoxNewDiscussion {
        display: block;
    }
}

.PageControls.Top {
    @include maxWidth {
        .NumberedPager {
            display: none;
        }
    }
}

.PageControls.Bottom {
    .NewDiscussion {
        display: none;
    }
}
